{block name=table-payments}
{if $payments }
	<div id="orders-list">
		<div class="panel-group" id="accordion">
			{foreach $payments as $payment}
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion" href="#{$payment.payment_id}"> 
							<span>
								{$payment.cart_closed_date} | <b>订单号：</b> {$payment.payment_transaction_no}
							</span>
							<span class="pull-right text-{$payment.status_category}"><b>{$payment.status_name}</b></span>
						</a>
					</h4>
				</div>
				<div id="{$payment.payment_id}" class="panel-collapse collapse">
					<div class="panel-body">
						<table class="top-margin" cellspacing="0" width="100%" cellpadding="0" border="0">
							<tr align="left">
								<th style="width: 50%" class="text-left">商品</th>
								<th style="min-width: 10%" class="text-center">数量</th>
								<th style="min-width:40px;" class="text-right">单价</th>
								<th style="min-width:75px;" class="text-right">小计</th>
							</tr>
							{foreach $payment.items as $item}
							<tr valign="top" class="text-left">
								{assign var=free value=0}
								<td>{if $item.cartitem_product_gst eq '0'}{assign var=free value=1} *{/if}
									{if $item.cartitem_custom_type}{$item.cartitem_custom_type}: {/if}{$item.cartitem_product_name} 
									{if $item.attributes } 
											{assign var='hasweek' value=0}
											{if $item.cartitem_class_flag eq 1 && $item.cartitem_enrolment_type eq 'T' } 
												【{getdatebyweekdaystartdate weekday=$item.class_weekday startdate=$item.term_start_date weeksafter=$item.attributes.0.cartitem_attr_attr_value_name-1 dateformat='Y/m/d'}】
											{else}
												{if $item.cartitem_product_id gt 0}
												{foreach from=$item.attributes item=attr name=attributesarr}
													{if $attr.cartitem_attr_attribute_name eq 'week'}
															{assign var='hasweek' value=$hasweek+1}
													{else}
														 / {$attr.cartitem_attr_attribute_name}: {$attr.cartitem_attr_attr_value_name}
													{/if} 
												{/foreach}
												{if $hasweek gt 0}
													【课程共 {$hasweek} 周】
												{/if}
												{/if}
											{/if}
										{/if}
								</td>
								<td class="text-center">{$item.cartitem_quantity}</td>
								<td class="text-right">{$CURRENCY_SYMBOL}{$item.cartitem_product_price|number_format:2:".":","}</td>
								<td class="text-right">{$CURRENCY_SYMBOL}{$item.cartitem_subtotal|number_format:2:".":","}</td>
							</tr>
							{/foreach}
							<!-- <tr valign="top" align="left">
								<td colspan="4"><hr></td>
							</tr> -->
							<tr valign="top">
								<td colspan="3" class="text-right rta"><strong>总商品金额</strong></td>
								<td style="text-align: right">{$CURRENCY_SYMBOL}{$payment.payment_subtotal|number_format:2:".":","}</td>
							</tr>
							{if $payment.payment_discount neq '0.00'}
							<tr valign="top">
								<td colspan="3" class="text-right rta"><strong>返现</strong></td>
								<td class="text-right">{$CURRENCY_SYMBOL}-{$payment.payment_discount|number_format:2:".":","}</td>
							</tr>
							{/if}
							{if $payment.payment_shipping_fee neq '0.00'}
							<tr valign="top">
								<td colspan="3" class="text-right rta"><strong>运费</strong></td>
								<td style="text-align: right">{$CURRENCY_SYMBOL}{$payment.payment_shipping_fee|number_format:2:".":","}</td>
							</tr>
							{/if}
							{if $payment.payment_additional neq '0.00'}
							<tr valign="top">
								<td colspan="3" class="text-right rta"><strong>{$payment.payment_additional_description}</strong></td>
								<td class="text-right">{$CURRENCY_SYMBOL}{$payment.payment_additional|number_format:2:".":","}</td>
							</tr>
							{/if}
							<!-- <tr valign="top">
								<td>{if $free}(*){$TAX_CODE} free item.{/if}</td>
								<td colspan="2" class="text-right rta"><strong>Incl. {$TAX_CODE}</strong></td>
								<td style="text-align: right">({$CURRENCY_SYMBOL}{$payment.payment_gst|number_format:2:".":","})</td>
							</tr> -->
							{if $payment.payment_surcharge neq '0.00'}
							<tr valign="top" class="rta">
								<td colspan="3" class="text-right rta"><strong>信用卡附件费</strong></td>
								<td class="text-right">{$CURRENCY_SYMBOL}{$payment.payment_surcharge|number_format:2:".":","}</td>
							</tr>
							{/if}
							<!-- <tr valign="top" align="left">
								<td colspan="4"><hr></td>
							</tr> -->
							<tr valign="top">
								<td colspan="3" class="text-right rta"><strong>应付总额</strong></td>
								<td style="text-align: right"><strong>{$CURRENCY_SYMBOL}{$payment.payment_total|number_format:2:".":","}</strong></td>
							</tr>
							<!-- <tr valign="top">
								<td colspan="4"><hr></td>
							</tr> -->
							{if $payment.payment_surcharge neq '0.00'}
							<tr valign="top" class="rta">
								<td colspan="3" class="text-right rta"><strong>信用卡附件费</strong></td>
								<td class="text-right">{$CURRENCY_SYMBOL}{$payment.payment_surcharge|number_format:2:".":","}</td>
							</tr>
							{/if}
							{if $payment.status_category eq 'pending'}
							<tr valign="top">
								<td colspan="5" class="text-right">
									<button type="button" class="btn btn-default">取消订单</button> 
									<a href="/payment?orderno={$payment.payment_transaction_no}" role="button" class="btn btn-danger">付款</a>
								</td>
							</tr>
							{/if}
							{if $payment.payment_charged_amount neq $payment.payment_total}
							<tr valign="top">
								<td colspan="3" class="text-right rta"><strong>首次付款</strong></td>
								<td style="text-align: right"><strong>{$CURRENCY_SYMBOL}{$payment.payment_charged_amount|number_format:2:".":","}</strong></td>
							</tr>
							{assign var='hasPending' value=0}
							{foreach $payment.debt as $debt}
								{if $debt.payment_id && $debt.debt_paid_date}
								<tr valign="top" align="left">
									<td colspan="3" class="text-right rta"><strong>付款 [{$debt.debt_paid_date|date_format:"%d/%m/%Y"}] - {$debt.payment_response_cardscheme}</strong></td>
									<td style="text-align: right"><strong>{$CURRENCY_SYMBOL}{$debt.payment_charged_amount|number_format:2:".":","}</strong></td>
								</tr>
								{else}
								{assign var='hasPending' value=$debt.debt_id}
								<tr valign="top" align="left" class="text-danger">
									<td colspan="3" class="text-right rta"><strong>待付款 [{$debt.debt_nextpayment_date|date_format:"%d/%m/%Y"}]</strong></td>
									<td style="text-align: right"><strong>{$CURRENCY_SYMBOL}{$debt.debt_amount|number_format:2:".":","}</strong></td>
								</tr>
								{/if}
							{/foreach}
							<tr valign="top" align="left">
								<td colspan="4"><hr></td>
							</tr>
							{/if}
						</table>
					</div>
				</div>
			</div>
			{/foreach}
		</div>
	</div>
{else}
	<div class="member-tab-content no-pay">
 		没有交易记录
 	</div> 
{/if}

{/block} 


